package com.gx.smart.building.ui.inspection.adapter

import android.util.SparseArray
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.gx.smart.building.ui.inspection.fragment.InspectionCompleteFragment
import com.gx.smart.building.ui.inspection.fragment.InspectionInCompleteFragment

/**
 * @author xiaosy
 * @create 2020/7/7
 * @Describe
 */
class PageAdapter(fragmentActivity: FragmentActivity) : FragmentStateAdapter(fragmentActivity) {
    private val list = SparseArray<Fragment>()
    private val fragment0 = InspectionInCompleteFragment.newInstance()
    private val fragment1 = InspectionCompleteFragment.newInstance()
    override fun createFragment(position: Int): Fragment {
        return list[position]
    }

    override fun getItemCount(): Int {
        return list.size()
    }

    init {
        list.put(0, fragment0)
        list.put(1, fragment1)
    }

    fun getItem(position: Int): Fragment {
        return list.get(position)
    }

}